const {ccclass, property} = cc._decorator;
import Global = require("./GlobalEvents");

@ccclass
export default class EndEvents extends cc.Component {  

    
    // LIFE-CYCLE CALLBACKS:
    btnClick(event, customEventData){
        if(customEventData==0){
            //cc.log("event=",event.type," data=",customEventData);
            this.node.runAction(cc.fadeOut(0.5));
            let callbak = function (){
                cc.director.loadScene("GameMenu");
            };
            this.scheduleOnce(callbak, 0.7);            
        }
    }

    onLoad () {
        let self = this;     

        // 加载背景 独立的SpriteFrame
        let bgrand = Math.ceil(Math.random() * 6) - 1;        
        Global.BGpic = bgrand;       

        //开启右上角的分享
        window["wx"].showShareMenu();        
        //监听右上角的分享调用
        cc.loader.loadRes("Icon_128",function(err,data){            
            window["wx"].onShareAppMessage(function(res){                
                return {                    
                    title: "猴哥有难，快来帮忙！",				
                    imageUrl: data.url,				
                    success(res){                        
                        console.log("转发成功!!!")},                        
                    fail(res){
                        console.log("转发失败!!!")}
                }		
            })	
        }); 
    }

    //start () {    }

    

    //update (dt) {    }
}
